<html>
<body>
<p>Reports variable definitions that are explicitly initialized with <code>null</code>.</p>
<p>There are 3 different cases of <code>var v: T = null</code>:</p>
<ol>
    <li><code>v</code> is an <em>optional</em> value<br>
        &rarr; use <code>Option[T]</code> type, which is idiomatic and type safe</li>
    <li><code>v</code> is an <em>uninitialized</em> value (a value must be assigned)<br>
        &rarr; use <code>_</code> (Scala 2) or <code>scala.compiletime.uninitialized</code> (Scala 3) as initializer,
          which is clear, concise, and platform-independent</li>
    <li>It is a performance <em>optimization</em> (you actually use the <code>null</code> value)<br>
        &rarr; explicitly suppressed the inspection for the unsafe code</li>
</ol>
<p>Two quickfixes will be offered:</p>
<ul>
    <li><em>Use _ initializer</em> will replace <code>null</code> with <code>_</code></li>
    <li><em>Use Option type</em> will replace the type of the variable with <code>Option</code> and initialize it with <code>None</code></li>
</ul>
<p><b>Example:</b></p>
<pre><code>
  class Test {
    var optional: String = null
    var uninit: String = null

    uninit = "initialized later"
  }
</code></pre>
<p>After the quick-fixes are applied:</p>
<pre><code>
  class Test {
    var optional: Option[String] = None
    var uninit: String = _

    uninit = "initialized later"
  }
</code></pre>
<!-- tooltip end -->
</body>
</html>